<template>
	<view class="DazisCommunity flex">
		<view class="head" @tap="navigateTo('/pages/PartnerActivitiesPage/PartnerActivitiesPage?id='+gfdata[0].id)">
			<image src="/static/images/DaziCommunity/notice.png" mode="" class="head_one"></image>
			<view class="head_two">{{gfdata[0].title}}</view>
		</view>
		<view class="tabs">
			<up-tabs :list="list1" @click="click" activeStyle="color: #0F4C97;" :scrollable="false">
			</up-tabs>
		</view>
		<view class="community_list">
			<template>
				<DaziCommunityNearTour :dataList="list" />
			</template>
			<view v-if="!isFinished" class="more" @click="getMore">获取更多</view>
		</view>
	</view>
</template>

<script>
	import {
		bbsList
	} from '../../api/bbs';
	import DaziCommunityNearTour from '../../components/DaziCommunityNearTour/DaziCommunityNearTour.vue';
	import {
		navigateTo,
		getProvider,
		showModal,
		uniLogin
	} from "../../utils/promise"
	import EntertainmentActivities from '../../components/EntertainmentActivities/EntertainmentActivities.vue';
	export default {
		data() {
			return {
				list1: [{
					name: '全部',
				}, {
					name: '周边游',
				}, {
					name: '本地美食',
				}, {
					name: '景区景点'
				}, {
					name: '娱乐活动'
				}, ],
				tabIndex: 0,
				current: 1,
				size: 1000,
				total: 0,
				bbsAll: [],
				list: [],
				firstReq: false,
				gfdata: []
			};
		},
		computed: {
			isFinished() {
				if (!this.firstReq) {
					return false
				}
				return this.list.length >= this.total
			}
		},
		onShow() {
			bbsList({
				type: 99
			}).then((res) => {
				const {
					code,
					data
				} = res
				if (code === 200) {
					this.gfdata = data.records
				}
			}).catch((err) => {
				console.log(err)
			})
			this.getbbsList(this.tabIndex)
		},
		methods: {
			navigateTo,
			getMore() {
				if (this.isFinished) return
				this.current++
				this.getbbsList(this.tabIndex)
			},
			//tabs
			click({
				index
			}) {
				this.tabIndex = index
				this.current = 1
				this.total = 0
				this.list = []
				this.getbbsList(this.tabIndex)
			},
			// goToNangChang() {
			// 	uni.navigateTo({
			// 		url: "/pages/NanChangPage/NanChangPage"
			// 	});
			// },
			getbbsList(index) {
				let params = {
					current: this.current,
					size: this.size
				}
				if (index - 1 >= 0) {
					params.type = index - 1
				}
				bbsList(params).then((res) => {
					const {
						code,
						data
					} = res
					if (code === 200) {
						this.list = [...this.list, ...data.records]
						this.total = data.total
						this.firstReq = true
					}
				}).catch((err) => {
					console.log(err)
				})
			},
		},

		components: {
			DaziCommunityNearTour,
			EntertainmentActivities
		}
	}
</script>

<style lang="less" scoped>
	.DazisCommunity {
		width: 100vw;
		background-color: rgb(247, 247, 247);
		box-sizing: border-box;
		font-family: 'PingFang SC';
		text-align: center;

		.community_list {
			overflow: auto;
			height: 85vh;
		}

		.more {
			margin: 20rpx 40rpx;
			padding: 10rpx 20rpx;
			background: #0F4C97;
			color: #ffffff;
			border-radius: 30rpx;
		}

		.head {
			display: flex;
			width: 750rpx;
			// height: 80rpx;
			box-sizing: border-box;
			padding: 20rpx;
			background: #FFF4DB;
			align-items: center;

			.head_one {
				width: 40rpx;
				height: 40rpx;
			}

			.head_two {
				font-weight: 400;
				font-size: 26rpx;
				letter-spacing: 0px;
				color: #804040;
				margin-left: 10rpx;


			}
		}

		.tabs {
			font-size: 28rpx;
			width: 750rpx;
			height: 90rpx;
			background: #FFFFFF;
			margin-top: 20rpx;
			display: flex;
			align-items: flex-end;
			justify-content: center;
			margin-top: 20rpx;
			padding: 20rpx 42rpx 0 42rpx !important;
			box-sizing: border-box;

			::v-deep .u-tabs__wrapper__nav {
				width: 100vw;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between !important;
			}

			::v-deep .u-tabs__wrapper__nav__line {
				background: #0F4C97 !important;

			}


		}
	}
</style>